<?php

namespace App\Kuafu\User\Controller\B;

use App\Kuafu\Base\Controller\BaseController;
use App\Kuafu\Common\Enum\CodeEnum;
use App\Kuafu\User\Service\PermissionsService;
use Illuminate\Http\Request;

class PermissionsController extends BaseController
{
    /**
     * 查询web 品牌所有权限列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getBrandPermissions(Request $request, int $roleId = 0)
    {
        $permission = new PermissionsService($request->header('brandId'), $request->header('shopId'), $roleId,
            CodeEnum::PLATFORM_B_BRAND);
        $return     = $permission->getPermissionsList();

        return $this->success($return);
    }

    /**
     * 查询pos 门店所有权限列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getShopPermissions(Request $request, int $roleId = 0)
    {
        $permission = new PermissionsService($request->header('brandId'), $request->header('shopId'), $roleId,
            CodeEnum::PLATFORM_POS);
        $return     = $permission->getPermissionsList();

        return $this->success($return);
    }

    /**
     * 查询商家app所有权限列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getMerchantPermissions(Request $request, int $roleId = 0)
    {
        $permission = new PermissionsService($request->header('brandId'), $request->header('shopId'), $roleId,
            CodeEnum::PLATFORM_BUSINESS);
        $return     = $permission->getPermissionsList();

        return $this->success($return);
    }
}
